//
//  YTFeedBackViewModel.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/5/11.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTFeedBackViewModel.h"
#import "YTUserProfileServices.h"

@interface YTFeedBackViewModel ()

@property (copy, nonatomic, readwrite) NSString *feedBackContent;

@property (strong, nonatomic, readwrite) RACSignal *feedBackContentSignal;
@property (strong, nonatomic, readwrite) RACCommand *submitCommand;

@end

@implementation YTFeedBackViewModel

- (void)initialize {
    [super initialize];
    
    _feedBackContentSignal = [[RACObserve(self, feedBackContent) distinctUntilChanged] map:^id(NSString *text) {
        return @((BOOL)(text.length >= 1));
    }];
    @weakify(self);
    _submitCommand = [[RACCommand alloc] initWithEnabled:_feedBackContentSignal signalBlock:^RACSignal *(id input) {
        @strongify(self);
        return [YTUserProfileServices userFeedBack:self.feedBackContent];
    }];
}

@end
